<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="../common.jsp"%>
<%@ taglib prefix="x" uri="/WEB-INF/im.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="cn.firstsoft.firstframe.util.ContextUtils"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理控制台 - 环境设置 - 通讯集成设置</title>
<%@ include file="/common/meta2.jsp"%>
<link href="${ctx_path}/admin/style.css" type="text/css" rel="stylesheet">
<style type="text/css">
	input.portal {
		border-width: 0px;
		vertical-align:middle;
	}
</style>
<script type="text/javascript">
	var im = "${im}";
	function setVisible(obj, visible) {
		if ( obj ) {
			if ( visible ) {
				obj.style.display = "";
			} else {
				obj.style.display = "none";
			}
		}
	}
	function onSelectChange(obj) {
		var v = obj.value;
		var form = document.forms.imForm;
		setVisible($("tbl_ucstar"), v == "ucstar");
		setVisible($("tbl_ucstar_portal"), v == "ucstar");
		setVisible($("btn_ucstar"), v == "ucstar");
		setVisible($("tbl_rtx"), v == "rtx");
		setVisible($("tbl_rtx_test"), v == "rtx");
		setVisible($("tbl_webim_portal"), v == "webim");
		setVisible($("btn_commit"), v != "none" || im != "none");
		setVisible($("btn_reset"), v != "none" || im != "none");
	}
	function submitIMForm() {
		if ( checkIMForm() ) {
			document.forms.imForm.submit();
		}
	}
	function resetIMForm() {
		document.forms.imForm.reset();
		setVisible($("tbl_ucstar"), im == "ucstar");
		setVisible($("tbl_ucstar_portal"), im == "ucstar");
		setVisible($("tbl_rtx"), im == "rtx");
		setVisible($("tbl_rtx_test"), im == "rtx");
		setVisible($("btn_ucstar"), im == "ucstar");
		setVisible($("tbl_webim_portal"), im == "webim");
	}
	function checkIMForm() {
		var msg = "";
		var form = document.forms.imForm;
		var focused = null;
		if ( form.im.value == "none" ) {
			return true;
		} else if ( form.im.value == "ucstar" ) {
			if ( form.ucstar_url.value == "" ) {
				msg = "UcSTAR服务器HTTP访问地址不能为空！\n" + msg;
				focused = form.ucstar_url;
			}
			if ( form.ucstar_port.value == "" ) {
				msg = "UcSTAR服务器端口不能为空！\n" + msg;
				focused = form.ucstar_port;
			}
			if ( form.ucstar_host.value == "" ) {
				msg = "UcSTAR服务器地址不能为空！\n" + msg;
				focused = form.ucstar_host;
			}
		} else if ( form.im.value == "rtx" ) {
			if ( form.rtx_url.value == "" ) {
				msg = "RTX Server地址不能为空！\n" + msg;
				focused = form.rtx_url;
			}
			if ( form.rtx_port.value == "" ) {
				msg = "RTX SERVER端口不能为空！\n" + msg;
				focused = form.rtx_port;
			}
			if ( form.rtx_host.value == "" ) {
				msg = "RTX HttpServer地址及端口不能为空！\n" + msg;
				focused = form.rtx_host;
			}
		} else if (form.im.value == "webim") {
			if ( form.webim_keeptime.value == "" ) {
				msg = "WEBIM消息记录保存时间不能为空！\n" + msg;
				focused = form.webim_keeptime;
			} else if (isNaN(form.webim_keeptime.value)){
				msg = "WEBIM消息记录保存时间必须为数字！\n" + msg;
				focused = form.webim_keeptime;
			} else if (form.webim_keeptime.value.indexOf(".") >= 0){
				msg = "WEBIM消息记录保存时间必须是整数！\n" + msg;
				focused = form.webim_keeptime;
			} else if (form.webim_keeptime.value < 0){
				msg = "WEBIM消息记录保存时间不能为负数！\n" + msg;
				focused = form.webim_keeptime;
			} else if (form.webim_keeptime.value > 9999){
				msg = "WEBIM消息记录保存时间最大值不能超过9999！\n" + msg;
				focused = form.webim_keeptime;
			} else if (form.webim_keeptime.value == 0){
				msg = "WEBIM消息记录保存时间不能为0！\n" + msg;
				focused = form.webim_keeptime;
			}
		}
		
		
		var ret = true;
		if ( msg.length > 0 ) {
			alert(msg);
			focused.focus();
			ret = false;
		}
		return ret;
	}
	function checkRTXTestForm() {
		var msg = "";
		var form = document.forms.rtxTestForm;
		var focused = null;
		if ( form.receiver.value == "" ) {
			msg = "接受者不能为空！";
			focused = form.receiver;
		}
		var ret = true;
		if ( msg.length > 0 ) {
			alert(msg);
			focused.focus();
			ret = false;
		}
		return ret;
	}
	function openIMConsole() {
		window.open("${ucstar_url}");
	}
</script>
</head>
<body>
	<form method="post" name="imForm" action="${ctx_path}/admin/comm.do?method=change" onsubmit="return checkIMForm();">
		<table width="100%" align="center">
			<thead>
				<tr>
					<th class="listViewPaginationTdS1" align="left" colspan="4">设置即时通讯工具集成参数</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">即时通讯工具:</td>
					<td colspan="3">
						<select name="im" onchange="onSelectChange(this);">
							<option value="none" ${x:selected(im, "none")}>无</option>
							<% if(ContextUtils.getInterfaceLicense("im_rtx")){%>
							<option value="rtx" ${x:selected(im, "rtx")}>RTX通讯集成</option>
							<%} %>
							<% if(ContextUtils.getInterfaceLicense("im_ucstar")){%>
							<option value="ucstar" ${x:selected(im, "ucstar")}>UcSTAR通讯集成</option>
							<%} %>
							
							<option value="webim" ${x:selected(im, "webim")}>系统自带通讯集成</option>
						
						</select>
					</td>
				</tr>
			</tbody>
		</table>
		<table id="tbl_ucstar" width="100%" align="center" style="display:${im eq 'ucstar' ? '' : 'none'}">
			<tbody>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">UcSTAR服务器地址:</td>
					<td>(127.0.0.1)</td>
					<td>
						<input type="text" name="ucstar_host" value="${ucstar_host}" />
					</td>
					<td>UcSTAR服务器所在IP地址</td>
				</tr>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">UcSTAR服务器端口:</td>
					<td>9090</td>
					<td>
						<input type="text" name="ucstar_port" value="${ucstar_port}" />
					</td>
					<td>UcSTAR服务器端口号</td>
				</tr>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">UcSTAR服务器HTTP访问地址:</td>
					<td>&nbsp;</td>
					<td>
						<input type="text" name="ucstar_url" value="${ucstar_url}" />
					</td>
					<td>访问UcSTAR服务器控制台地址</td>
				</tr>
			</tbody>
		</table>
		<table id="tbl_ucstar_portal" width="100%" align="center" style="display:${im eq 'ucstar' ? '' : 'none'}">
			<thead>
				<tr>
					<th class="listViewPaginationTdS1" align="left" colspan="4">设置协同微门户显示数据</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td class="dataLabel" width="30%" style="align:right; padding-top:2px; vertical-align:top;">默认显示值:</td>
					<td colspan="3">
						<input class="portal" type="checkbox" name="portal" value="1" ${x:checked(mask, 1)} />协同审批
						<input class="portal" type="checkbox" name="portal" value="2" ${x:checked(mask, 2)} />协同工作
						<input class="portal" type="checkbox" name="portal" value="4" ${x:checked(mask, 4)} />知识中心
						<input class="portal" type="checkbox" name="portal" value="8" ${x:checked(mask, 8)} />通知公告<br />
						<input class="portal" type="checkbox" name="portal" value="16" ${x:checked(mask, 16)} />新闻中心
						<input class="portal" type="checkbox" name="portal" value="32" ${x:checked(mask, 32)} />任务管理
						<input class="portal" type="checkbox" name="portal" value="64" ${x:checked(mask, 64)} />会议管理
						<input class="portal" type="checkbox" name="portal" value="128" ${x:checked(mask, 128)} />在线论坛<br />
						<input class="portal" type="checkbox" name="portal" value="256" ${x:checked(mask, 256)} />问卷调查
						<input class="portal" type="checkbox" name="portal" value="512" ${x:checked(mask, 512)} />电子邮件
					</td>
				</tr>
			</tbody>
		</table>
		<table id="tbl_rtx" width="100%" align="center" style="display:${im eq 'rtx' ? '' : 'none'}">
			<tbody>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">RTX Server地址:</td>
					<td>(127.0.0.1)</td>
					<td>
						<input type="text" name="rtx_host" value="${rtx_host}" />
					</td>
					<td>通过RTX服务器地址及端口，获得用户状态</td>
				</tr>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">RTX SERVER端口:</td>
					<td>9090</td>
					<td>
						<input type="text" name="rtx_port" value="${rtx_port}" />
					</td>
					<td>通过RTX服务器地址及端口，获得用户状态</td>
				</tr>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">RTX HttpServer地址及端口:</td>
					<td>&nbsp;</td>
					<td>
						<input type="text" name="rtx_url" value="${rtx_url}" />
					</td>
					<td>此设置主要用于使用WEB方式发送消息到RTX服务器</td>
				</tr>
			</tbody>
		</table>
		
		<table id="tbl_webim_portal" width="100%" align="center" style="display:${im eq 'webim' ? '' : 'none'};margin-top:60px;">
			<thead>
				<tr>
					<th class="listViewPaginationTdS1" align="left" colspan="4">设置定时清理</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td height="50px" width="30%" style="align:left;">
						<div style="width:10px;float:left;padding-top:3px;">&nbsp;</div>
						<div style="float:left;padding-top:3px;"><b>消息记录保存时间</b></div>
						<div style="float:left;"><input type="text" name="webim_keeptime" style="width:30px;text-align:center;border-left:0px;border-top:0px;border-right:0px;border-bottom:1px solid #000000;" value="${webim_keeptime}"></div>
						<div style="float:left;padding-top:3px;"><b>月</b></div>
					</td>
					<td height="50px" width="20%" style="align:right;">
						&nbsp;
					</td>
					<td height="50px" width="20%" style="align:right;">
						&nbsp;
					</td>
					<td height="50px" width="30%" style="align:right;">
						<div style="padding-top:3px;">月份最多可输入四位数，不支持输入0或小数.</div>
					</td>
				</tr>
			</tbody>
		</table>
		
		
	</form>
	<form method="post" name="rtxTestForm" action="${ctx_path}/admin/comm.do?method=testrtx" onsubmit="return checkRTXTestForm();">
		<table id="tbl_rtx_test" width="100%" align="center" style="display:${im eq 'rtx' ? '' : 'none'}">
			<thead>
				<tr>
					<th class="listViewPaginationTdS1" align="left" colspan="2">RTX测试</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;" rowspan="2">&nbsp;</td>
					<td>影响RTX正常使用的主要设置在RTX的服务器上，RTX服务器会检查是否允许OA服务器的IP地址或者域名向其发送消息！限制设置在RTX服务器的RTXServer\SDKProperty.xml文件中</td>
				</tr>
				<tr>
					<td>
						当前设置：<br />
						RTX Server地址:${rtx_host}<br />
						RTX Server端口:${rtx_port}<br />
						RTX HTTP Server地址及端口:${rtx_url}<br />
						测试程序将向接收者发送一条内容为”RTX测试“的通知消息
					</td>
				</tr>
				<tr>
					<td class="dataLabel" width="30%" style="align:right;">RTX接收者:</td>
					<td>
						<input type="text" name="receiver" value=""> <input type="submit" name="subt" value="测试链接">
					</td>
				</tr>
			</tbody>
		</table>
	</form>
	<div style="margin-left:2px;">
		<input id="btn_commit" class="button" type="button" value="&nbsp;提&nbsp;&nbsp;交&nbsp;" onclick="submitIMForm();" style="display:${im eq 'none' ? 'none' : ''}" />
		<input id="btn_reset" class="button" type="button" value="&nbsp;重&nbsp;&nbsp;置&nbsp;" onclick="resetIMForm();" style="display:${im eq 'none' ? 'none' : ''}" />
		<input id="btn_ucstar" class="button" type="button" style="margin-left:50px; display:${im eq 'ucstar' ? '' : 'none'}" value="打开UcSTAR管理控制台" onclick="openIMConsole();" />
	</div>
</body>
</html>